#include <iostream>
#include <string>
#include <cstring>

using namespace std;
void test_length_and_cut();
int main()
{
    // test_length_and_cut();
    return 0;
}

void test_length_and_cut()
{
    char name1[10];
   
    cout << "please input your name:" << endl;
    cin.getline(name1, 10);
    //sizeof获取的是系统分配的存储空间，strlen是实际占用的空间
    cout << "name1 length=" << strlen(name1) << " and sizeof=" << sizeof(name1) << endl;
    //截取字符串
    char name2[20] = "MikeWongAA";
    name2[5] = '\0';
    cout << "name2 after cutting: " << name2 << endl;
}
